package com.listening.works.web.common;

import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 登陆Controller
 * 
 * @author Listening
 * 
 */
@Controller
@RequestMapping("/login")
public class LoginController {

	/**
	 * 初始化登陆页面
	 * 
	 * @return
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String handleLoginPage() {
		return "common/login";
	}

	@RequestMapping(method = RequestMethod.POST)
	public String fail(@RequestParam(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM) String userName, Model model) {
		model.addAttribute(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM, userName);
		return "common/login";
	}
}
